//
//  NCFilterBottomView.swift
//  KMNavigationBarTransition
//
//  Created by 张文晏 on 2018/12/24.
//

import UIKit

public class NCFilterBottomView: UIView {
    
    // MARK: - Subviews
    let resetBtn = NCButton()
    let confirmBtn = NCButton()
    
    // MARK: - Variables
    public var resetClosure: (() -> Void)?
    public var confirmClosure: (() -> Void)?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupUI()
    }
    
    func setupUI() {
        let line = UIView()
        addSubview(line)
        line.snp.makeConstraints { make in
            make.top.leading.trailing.equalToSuperview()
            make.height.equalTo(1)
        }
        addSubview(resetBtn)
        resetBtn.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.centerY.equalToSuperview()
        }
        resetBtn.style = .gray
        resetBtn.setTitle("清空条件", for: .normal)
        resetBtn.set(font: UIFont.systemFont(ofSize: 16))
        resetBtn.addTarget(self, action: #selector(resetBtnClick), for: .touchUpInside)
        
        addSubview(confirmBtn)
        confirmBtn.snp.makeConstraints { make in
            make.leading.equalTo(resetBtn.snp.trailing).offset(16)
            make.trailing.equalTo(-16)
            make.width.equalTo(resetBtn)
            make.centerY.equalToSuperview()
        }
        confirmBtn.style = .theme
        confirmBtn.setTitle("确定", for: .normal)
        confirmBtn.set(font: UIFont.systemFont(ofSize: 16))
        confirmBtn.addTarget(self, action: #selector(confirmBtnClick), for: .touchUpInside)
        
    }
    
    @objc func resetBtnClick() { resetClosure?() }
    
    @objc func confirmBtnClick() { confirmClosure?() }
    
}
